/**
 * 
 */
package com.fan.shop.services;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import org.springframework.transaction.annotation.Transactional;

import com.fan.shop.dao.TransactionReferenceDao;
import com.fan.shop.domain.TransactionReference;

/**
 * @author Fan
 * 
 */
@Named("transactionReferenceService")
@Transactional(readOnly = true)
public class TransactionReferenceServiceImpl implements TransactionReferenceService {

	private String groupCode;
	
	@Inject
	@Named("transactionReferenceDao")
	private TransactionReferenceDao transactionReferenceDao;

	public TransactionReferenceDao getTransactionReferenceDao() {
		return transactionReferenceDao;
	}

	public void setTransactionReferenceDao(
			TransactionReferenceDao transactionReferenceDao) {
		this.transactionReferenceDao = transactionReferenceDao;
	}

	public List<TransactionReference> getAllTransactionReferences() {
		return transactionReferenceDao.getAllTransactionReferences();
	}

	public TransactionReference getTransactionReference(String name) {
		return transactionReferenceDao.getTransactionReference(name);
	}

	public boolean hasTransactionReference(String name) {
		return transactionReferenceDao.hasTransactionReference(name);
	}

	public int getSize() {
		return transactionReferenceDao.getSize();
	}

	@Transactional(readOnly = false)
	public void addTransactionReference(
			TransactionReference transactionReference) {
		transactionReferenceDao.addTransactionReference(transactionReference);
	}

	@Transactional(readOnly = false)
	public void updateTransactionReference(
			TransactionReference transactionReference) {
		transactionReferenceDao
				.updateTransactionReference(transactionReference);
	}

	@Transactional(readOnly = false)
	public void deleteTransactionReference(
			TransactionReference transactionReference) {
		transactionReferenceDao
				.deleteTransactionReference(transactionReference);
	}

	@SuppressWarnings("rawtypes")
	public List getList() {
		if(groupCode == null || groupCode.length() == 0)
		{
		return getAllTransactionReferences();
		}
		else
		{
			return transactionReferenceDao.getListByGroup(groupCode);
		}
	}

	public List<String> getColumnNames() {
		return transactionReferenceDao.getColumnNames();
	}

	public int getColumnsSize() {
		return getColumnNames().size();
	}

	public String getGroupCode() {
		return groupCode;
	}

	public void setGroupCode(String groupCode) {
		this.groupCode = groupCode;
	}

	public Object copy(Object obj) {
		// TODO Auto-generated method stub
		return null;
	}


}
